﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Web;

namespace SocialShare.BLL
{
    public class ConfigReader
    {
        public String ReadConfigurationValue(String configFileFullName,String configKey)
        {
            FileInfo fInfo = new FileInfo(HttpContext.Current.Server.MapPath(configFileFullName));
            String configValue=String.Empty;
             if (fInfo.Exists)
             {
                 XmlDocument doc = new XmlDocument();

                 doc.Load(fInfo.FullName);
                 XmlNodeList list = doc.GetElementsByTagName("CONFIGURATIONS");
                 if (list != null && list.Count > 0)
                 {
                     foreach (XmlNode node in list)
                     {
                         XmlNode fileNode = node.SelectSingleNode(configKey);
                         configValue = fileNode.InnerText;
                     }
                 }
             }

             return configValue;
        }

        public String ReadEmailTemplate(String templateName)
        {
            FileInfo fInfo = new FileInfo(HttpContext.Current.Server.MapPath(templateName));
            if (fInfo.Exists)
            {
                return File.ReadAllText(fInfo.FullName);              
            }


            return String.Empty;
        }
    }
}
